/**
 * @DemoService.java  COPYRIGHT xiaojian
 * 
 * Created on 2019年7月12日 下午2:18:22
 */
package xj.toolkit.plugin.demo;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author <a href="mailto:cxj2000@gmail.com">xiaojian.cao</a>
 *
 */
@Service("demoService")
public class DemoService {
	
	public static final Logger logger = LoggerFactory.getLogger(DemoService.class);

	@Value("${msg}")
	public String msg = null;
	
	@Value("${enable}")
	public boolean enable = true;
	
	@PostConstruct
	public void start() {
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				
				while (enable) {
					try {
						Thread.sleep(10 * 1000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					logger.error("-------->" + msg);
				}
				
			}
		}).start();
	}
	
	@PreDestroy
	public void stop() {
		enable = false;
	}
}
